# Test if (x0,y0) is in the Mandelbrot set or not
def in_mandel(x0: float, y0: float, n: int) -> int:
    x = 0
    y = 0
    xtemp = 0
    while (n > 0):
        xtemp = x*x - y*y + x0
        y = 2*x*y + y0
        x = xtemp
        n -= 1
        if x*x + y*y > 4:
            return 0
    return 1


if '__main__' == __name__:
    
    from PyCmpltrtok.common import sep
    
    pairs = [
        [0, 0],
        [-0.74543, 0.11301],
        [-1.4011, 0.60206],
        [1, 1],
        [2, 2],
        [3, 3],
    ]
    for i in range(4):
        n = i + 1
        sep(n)
        for p in pairs:
            print(p, '->', in_mandel(p[0], p[1], n))
        